Retry Policies
Retry policies allow workflow execution to repeat an operation when execution fails. Retries are particularly useful for operations that may fail temporarily, such as external service calls, network requests, AI provider calls, or other transient operations. In BindAI, retry behavior is handled by the workflow execution layer.What Is a Retry Policy?
A retry policy defines how failed execution should be attempted again. Conceptually:Why Use Retries?
Retries are useful when an operation can reasonably succeed if attempted again. Common examples include:- External API calls
- AI provider requests
- Network operations
- Database operations
- Cloud services
- External integrations
- Temporary service failures
Retry Policy Configuration
BindAI provides retry-policy configuration for controlling retry behavior. The retry policy currently defines configuration for:
The current executor uses
max_attempts to control the number of attempts.
The delay_seconds and exponential_backoff settings are currently defined as configuration fields but are not yet applied by the executor’s retry loop.
Therefore, applications should not currently assume that these settings introduce an actual delay or exponential backoff.
How Retries Work
Retry handling occurs when workflow execution raises an exception. Conceptually:Maximum Attempts
max_attempts controls the maximum number of executions allowed for the failed operation.
For example:
max_attempts=1means no retrymax_attempts=2allows one retrymax_attempts=3allows two retries
Successful Retry
If an operation fails initially but succeeds on a later attempt, normal workflow execution continues. Conceptually:Retry Without a Policy
If execution raises an exception and no retry policy applies, the failure follows the normal workflow error-handling path. Conceptually:Retry State
The workflow execution layer tracks retry progress while handling a failed operation. The current implementation maintains retry-attempt state internally during execution. This state is used to determine whether another attempt is permitted. Documentation should treat the retry counter and related execution-context fields as implementation details unless they are explicitly exposed as part of BindAI’s supported public API.Retry Delay and Backoff
The retry policy currently defines:delay_seconds and exponential_backoff should be considered configuration reserved for retry-delay behavior rather than active runtime features.
Retryable Exceptions
The current retry implementation does not define a built-in list of retryable exception types. When a retry policy applies, exceptions raised during node execution enter the retry handling. There is currently no documented configuration such as:Idempotency and Safe Retries
Retries can be dangerous for operations that produce side effects. For example:- Idempotency
- Duplicate requests
- Transaction boundaries
- External service behavior
- Unique request identifiers
- Partial completion
- Provider-specific retry guidance
Retry vs Loop
Retries and loops both execute operations repeatedly, but they have different purposes.
Use a retry when an operation failed and another attempt may succeed.
Use a loop when repetition is part of the intended workflow logic.
Retry vs Parallel Execution
Retry and parallel execution solve different problems. Parallel execution answers:Which independent operations can proceed separately?Retry answers:
What should happen when an operation fails?They can be combined. For example:
Retry and Timeout
Retries and timeouts operate at different levels. A retry controls what happens after an operation fails. A timeout limits how long an operation or workflow is allowed to run, depending on the configured timeout scope. Conceptually:Failure After Retries
When all permitted attempts fail, the workflow follows its normal failure-handling path. Conceptually:Compensation
Compensation is separate from retry behavior. A retry asks:Should this failed operation be attempted again?Compensation asks:
What should the workflow do when the overall operation ultimately fails?For workflows that support compensation callbacks, compensation can be used as part of final failure handling. Conceptually:
External Services
Retries are particularly useful around external services that may experience temporary failures. Examples include:- HTTP APIs
- AI providers
- Databases
- Cloud services
- SaaS integrations
- Network services
AI Provider Retries
AI provider requests may fail because of temporary network conditions, service availability, or provider-side errors. A retry can sometimes recover from such failures:Database Retries
Database operations can also encounter transient failures. Potential examples include:- Temporary connection failures
- Network interruptions
- Connection pool exhaustion
- Temporary service unavailability
External Integration Retries
Connections to external services may also be wrapped by retry behavior. For example:Retry and Workflow State
Retrying an operation should not be confused with starting a new workflow. Conceptually:State and Side Effects
Consider:- Idempotent
- Transactional where appropriate
- Safe to repeat
- Explicit about partial state
- Resistant to duplicate side effects
Testing Retry Behavior
Retry behavior should be tested explicitly. Important cases include:- Operation succeeds immediately
- Operation fails once and then succeeds
- Operation fails multiple times and then succeeds
- Operation fails on every attempt
- Retry policy is absent
max_attempts=1- Maximum attempts are reached
- An exception is raised during execution
- Retried operations interact with external services
- Retried operations modify state
- A workflow ultimately enters failure handling
Testing Side Effects
Retry tests should also verify that repeated execution does not create unintended side effects. For example:Observability
Retry behavior is easier to diagnose when execution records contain useful information. Useful observability data can include:- Operation name
- Attempt number
- Failure reason
- Total attempts
- Final status
- Execution duration
- Retry-related events
- External service response information
Best Practices
- Set a reasonable
max_attempts. - Use retries only where repeated execution is safe.
- Prefer idempotent operations for retryable work.
- Be especially careful with external side effects.
- Do not assume every exception is transient.
- Remember that the current implementation does not filter exception types.
- Do not assume
delay_secondscurrently pauses execution. - Do not assume
exponential_backoffis currently active. - Consider timeouts for operations that may take a long time.
- Respect external-service rate limits.
- Test both successful and exhausted retries.
- Test state and side effects across repeated attempts.
- Keep retry behavior separate from business-logic loops.
Current BindAI Scope
BindAI currently provides retry behavior as part of workflow execution. The current retry implementation supports:- Configurable maximum attempts
- Retry handling for node execution failures
- Immediate re-execution after failure
- Normal workflow continuation after successful retry
- Normal workflow failure handling after attempts are exhausted
delay_secondsexponential_backoff
API Accuracy
Retry behavior is part of the workflow execution system. Internal implementation details such as:- Retry counters
- Execution-context fields
- Executor retry loops
- Internal failure state
- Persistence operations
- Retry event internals
Summary
BindAI retry policies allow failed workflow operations to be attempted again. The current implementation usesmax_attempts to determine how many attempts are allowed, including the initial attempt.
For example:
delay_seconds and exponential_backoff are defined by the retry policy, they are not currently applied by the executor.
The implementation also does not currently provide exception-type filtering.
Retries are therefore a simple executor-level failure-recovery mechanism. They should be used carefully, particularly around external services and operations with side effects.